package com.spzx.channel.controller;

import com.spzx.channel.service.IIndexService;
import com.spzx.common.core.web.controller.BaseController;
import com.spzx.common.core.web.domain.AjaxResult;
import com.spzx.common.core.web.page.TableDataInfo;
import com.spzx.product.api.domain.SkuQuery;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * ClassName: ProductController
 * Package: com.spzx.channel.controller
 * Description:
 */
@Slf4j
@RestController
@Tag(name = "首页管理")
public class IndexController extends BaseController {
    @Autowired
    private IIndexService indexService;

    @Operation(summary = "获取首页数据")
    @GetMapping("/index")
    public AjaxResult index(){
        return success(indexService.getIndexData());
    }

    @Operation(summary = "获取商品列表")
    @GetMapping("/list/skuList/{pageNum}/{pageSize}")
    public TableDataInfo skuList(@Parameter(name = "pageNum", description = "当前页码", required = true)
                                 @PathVariable Integer pageNum,
                                 @Parameter(name = "pageSize", description = "每页记录数", required = true)
                                 @PathVariable Integer pageSize,
                                 SkuQuery skuQuery) {
        TableDataInfo dataInfo = indexService.getSkuList(pageNum,pageSize,skuQuery);
        return dataInfo;
    }


}
